<?php


namespace app\common\model;
use think\facade\Db;

class Attr extends Base
{
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = true;
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

    public function ajaxGroupNames($group_name,$group_id = 0){
        if(empty($group_name)){
            return 1;
        }
        //组装where条件
        $where = array();
        $where[] = array('group_name','=',$group_name);
        if($group_id > 0){
            $where[] =  array('group_id','<>',$group_id);
        }
        return Db::name('attr')->where($where)->find();
    }

    public function ajaxScreenNames($screenid,$group_id = 0){
        if(empty($screenid)){
            return 1;
        }
        //组装where条件
        $where = array();
        $where[] = array('screenid','=',$screenid);
        if($group_id > 0){
            $where[] =  array('group_id','<>',$group_id);
        }
        return Db::name('attr')->where($where)->find();
    }

    public function ajaxGroupTitles($group_title,$group_id = 0){
        if(empty($group_title)){
            return 1;
        }
        //组装where条件
        $where = array();
        $where[] = array('group_title','=',$group_title);
        if($group_id > 0){
            $where[] =  array('group_id','<>',$group_id);
        }
        return Db::name('attr')->where($where)->find();
    }
}